package Events.gui;

import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

import structures.Pace;
import structures.Rations;
import Events.StartGameEvent;

public class SetupSpaceshipTemp extends JPanel implements MouseListener {
	
	private static final long serialVersionUID = 1L;
	
	private StartGameEvent sge;
	private JLabel lblRations, lblPace;
	private JRadioButton rdbP50, rdbP75, rdbP100, rdbP125;
	private JRadioButton rdbR50, rdbR75, rdbR100, rdbR125;
	private ButtonGroup bgPace, bgRations;
	private JButton btnNext;
	
	public SetupSpaceshipTemp(StartGameEvent sge){
		super();
		setLayout(null);
		this.setPreferredSize(new Dimension(600,500));
		
		this.sge = sge;
		
		lblRations = new JLabel("Set Rations:");
		lblRations.setBounds(73, 60, 109, 14);
		add(lblRations);
		
		bgRations = new ButtonGroup();
		
		rdbR50 = new JRadioButton("Eat Poorly", false);
		rdbR50.setBounds(103, 76, 129, 23);
		bgRations.add(rdbR50);
		add(rdbR50);
		
		rdbR75 = new JRadioButton("Eat Sufficiently", true);
		rdbR75.setBounds(105, 102, 129, 23);
		bgRations.add(rdbR75);
		add(rdbR75);
		
		rdbR100 = new JRadioButton("Eat Well", false);
		rdbR100.setBounds(103, 128, 129, 23);
		bgRations.add(rdbR100);
		add(rdbR100);
		
		rdbR125 = new JRadioButton("Overindulge", false);
		rdbR125.setBounds(103, 154, 129, 23);
		bgRations.add(rdbR125);
		add(rdbR125);
		
		lblPace = new JLabel("Set Pace:");
		lblPace.setBounds(284, 60, 109, 14);
		add(lblPace);
		
		bgPace = new ButtonGroup();
		
		rdbP50 = new JRadioButton("Travel Slow", false);
		rdbP50.setBounds(303, 76, 149, 23);
		bgPace.add(rdbP50);
		add(rdbP50);
		
		rdbP75 = new JRadioButton("Travel Cautiously", false);
		rdbP75.setBounds(303, 102, 149, 23);
		bgPace.add(rdbP75);
		add(rdbP75);
		
		rdbP100 = new JRadioButton("Travel Normally", true);
		rdbP100.setBounds(303, 128, 149, 23);
		bgPace.add(rdbP100);
		add(rdbP100);
		
		rdbP125 = new JRadioButton("Travel Quickly", false);
		rdbP125.setBounds(303, 154, 149, 23);
		bgPace.add(rdbP125);
		add(rdbP125);
		
		btnNext = new JButton("To the Store");
		btnNext.setBounds(172, 282, 130, 23);
		btnNext.addMouseListener(this);
		add(btnNext);
		
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		if(e.getSource() == btnNext){
			Pace pace;
			Rations rations;
			if(rdbP50.isSelected())
				pace = Pace.SLOW;
			else if(rdbP75.isSelected())
				pace = Pace.CAUTIOUSLY;
			else if(rdbP100.isSelected())
				pace = Pace.NORMALLY;
			else
				pace = Pace.QUICKLY;
			if(rdbR50.isSelected())
				rations = Rations.POORLY;
			else if(rdbR75.isSelected())
				rations = Rations.SUFFICIENTLY;
			else if(rdbR100.isSelected())
				rations = Rations.WELL;
			else
				rations = Rations.OVERINDULGE;
			sge.setPaceRations(pace, rations);
		}

	}

	@Override
	public void mouseEntered(MouseEvent e) {}

	@Override
	public void mouseExited(MouseEvent e) {}

	@Override
	public void mousePressed(MouseEvent e) {}

	@Override
	public void mouseReleased(MouseEvent e) {}

}
